#ifndef ENCH265_H
#define ENCH265_H

#include "ldRKInc.h"


typedef struct
{
    int      nChn;
    MppApi * mpi;
    MppCtx   ctx;
    int cfg_frame_width;        // = 1280;
    int cfg_frame_height;       // = 768;
    int cfg_hor_stride;         // = MPP_ALIGN(cfg_frame_width, 16);	// for YUV420P it has tobe devided to 16
    int cfg_ver_stride;         // = MPP_ALIGN(cfg_frame_height, 16);	// for YUV420P it has tobe devided to 16
    MppFrameFormat cfg_foramt;  // = MPP_FMT_YUV420P;	// format of input frame YUV420P MppFrameFormat inside mpp_frame.h
    MppCodingType cfg_type;     // = MPP_VIDEO_CodingAVC;
    int cfg_bps;                // = 600000;
    int cfg_bps_min;            //= 400000;
    int cfg_bps_max;            // = 800000;
    int cfg_rc_mode;            //= 0;	//0:vbr 1:cbr 2:avbr 3:cvbr 4:fixqp;
    int cfg_frame_num;          // = 0;	//max encoding frame number

    int cfg_gop_mode;
    int cfg_gop_len;
    int cfg_vi_len;
    int cfg_fps_in_flex0;
    int cfg_fps_in_den;     //1;
    int cfg_fps_in_num;     //8// input fps
    int cfg_fps_out_flex0;
    int cfg_fps_out_den;    // 1;
    int cfg_fps_out_num;   // 8;
    int cfg_frame_size;
    int cfg_header_size;
    int cfg_quiet;

    MppBufferGroup buf_grp;
    MppBuffer frm_buf;
    MppBuffer pkt_buf;
    MppPollType timeout;            // = MPP_POLL_BLOCK;
    MppEncCfg cfg;

    MppEncSeiMode cfg_sei_mode;  // = MPP_ENC_SEI_MODE_ONE_FRAME;

    int      isGetSPS;
    int      nSpsPpsLen;
    uint8_t  ucSpsPpsBuf[256];

    char*    pYUVBuff;
    char*    pH265Buff;

}stEncCtx;

int  encH265Init(stEncCtx*  pstEncH265,int nChannel,
                 int nWidth,int nHeight,
                 MppFrameFormat  src_fmt,
                 MppCodingType   code_type,
                 int   in_fps,
                 int   in_gop,
                 int   in_bw,
                 bool  isRtsp);

int  encH265Frame(stEncCtx*  pstEncH265,uint8_t* pYUVSrc,uint8_t*  pH265Pack);
int  encH265Release(stEncCtx*  pstEncH265);

#endif // ENCH265_H
